home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / ee1091.zip / EEIBM.C < prev    next >
Text File  |  1991-10-11  |  5KB  |  143 lines

  1. /* eeibm.c -- machine dependent functions for ee.c
  2.  
  3. This program started around 08-08-88. Don't have much documentation for
  4. previous changes. It will be added this time. 09-19-91. This is a small,
  5. portable word processor. A good program practice to write portable screen
  6. output code.
  7.  
  8. */
  9. /*    Software requirment specifications:
  10.  
  11. Edit key: It is difficult to follow any word processor since every ones
  12. are different. TC arrange the editing keys by keyboard layout while emacs
  13. by the meaning of the function. A precise definitions for each editing key
  14. are very important in help screen.
  15.  
  16. Screen: The first line contain status report and is also used for error
  17. display, user input prompt etc. The rest of the lines are used for main
  18. editing area. Scrolls are nice. But scroll functions in course package on
  19. unix does not work very well except compiled with gcc and courseX.
  20.  
  21. Searching: TC style is very good. For replace, a possible example is
  22. /more/less/wn.
  23.  
  24. Block: A common block buffer is used to copy to a different file. TC's
  25. block method will not be used. Block commands should start with a mark
  26. command. Temporary file is used for large block.
  27.  
  28. Blanks: If the file contains tabs, then traillings are deleted and blanks
  29. are replaced with tab whenever appropriate. Otherwise, blanks are not
  30. disturbed. This is useful for data files.
  31.  
  32. Modes: Autofill, overwrite, tab (will convert on save), prefix (control-p
  33. pressed), changed (will ask to save on exit), position (show position),
  34. auto-indent (good for writing program on mainframe), format to cursor
  35. position (to write online document).
  36.  
  37. Compiler options: Editing keys, color(white/blue) or mono (bold/normal),
  38. default tab size should be 8 to be compatible with other word processor.
  39. Buffer size is also fixed at compile time.
  40.  
  41. Big file: Read will stop when editor buffer is almost full. Dump to disk
  42. start as soon as buffer is full in sequential manner.
  43.  
  44. Portability: It is written for MSDOS, unix and VMS operating system with
  45. minimum machine dependent functions. Far pointer should not be used on
  46. MSDOS but it would be nice to be able to compile with compact module. C++
  47. should not be used until it is also available for mainframe.
  48.  
  49. */
  50. /* Implementation issues
  51.  
  52. Program can be loosely grouped by: screen, cursor move, search, block,
  53. file and window, misc, mainloop, main.
  54.  
  55. This file is not needed when compiled by TC 2.0. It emulate the following
  56. functions: cprintf, putch, clreol, clrscr, insline, delline, gotoxy,
  57. highvideo, lowvideo, getch. These two not needed for TC to emulate
  58. mainframe: ttopen, ttclose. Also to observe the different behavior of
  59. these: system, rename, fopen.
  60.  
  61. Internally, the whole editing buffer is treated like a array. Each line
  62. is a string which ends with a 0. Malloc() is not used.
  63.  
  64. */
  65.  
  66. /* define one of the following, not all of them work */
  67. #define ANS  0  /* using ansi code, for VMS */
  68. #define CVM  0  /* curses VMS, does not work yet */
  69. #define CUN  0  /* curses unix, no hardware scroll */
  70. #define CUX  1  /* cursesX unix, works best with gcc */
  71.  
  72. #if CUN | CUX | CMV | ANS
  73. #define AMAX  0xD0000    /* main buffer size */
  74. #define BMAX  0x400     /* block size */
  75. #define YTOP  0        /* first line */
  76. #endif
  77.  
  78. #if CMV
  79. #include <curses.h>
  80. #define ttopen() initscr();\
  81.   crmode();system("set term/pasthru/nottsyc/noecho");\
  82.   swhfull=LINES-3;sww=COLS-2
  83. /* #define OPEN "r","var=lf","fmt=fix" */
  84. #define unlink(s) remove(s)
  85. #endif
  86. #if CUN
  87. #include <curses.h>
  88. #define ttopen() initscr();\
  89.   raw();noecho();swhfull=LINES-3;sww=COLS-2
  90. #endif
  91. #if CUX
  92. #include <cursesX.h>
  93. #define ttopen() initscr();\
  94.   idlok(stdscr,1);\
  95.   raw();noecho();swhfull=LINES-3;sww=COLS-2
  96. #endif
  97.  
  98. #if CUN | CUX | CMV
  99. #define cprintf(x,y)      printw(x,y)
  100. #define cputs(s)      addstr(s)
  101. #define putch(c)      addch(c)
  102. #define clreol()      clrtoeol()
  103. #define clrscr()      erase()
  104. #define insline()     insertln()
  105. #define delline()     deleteln()
  106. #define gotoxy(x,y)      move(y,x-1)
  107. #define highvideo()     standout()
  108. #define lowvideo()      standend()
  109. #define ttclose()     addch('\n');refresh();endwin()
  110. #endif
  111.  
  112. #if ANS
  113. /* deleted */
  114. #endif
  115.  
  116. /* honest get a key */
  117. int get_key()
  118. {
  119.   static  char k1[]="ABCDrpl";
  120.   static  char k2[]="EXDSdsh";
  121.   int key;
  122.   char  *s;
  123. #ifndef TYEP
  124.   refresh();
  125.   key = getch();
  126. #else /* type ahead, does not works well */
  127.   nodelay(stdscr, 1);
  128.   if((key = getch()) == ERR) {
  129.     refresh();
  130.     nodelay(stdscr, 0);
  131.     key = getch();
  132.   }
  133. #endif
  134.   if(key == 127) return 8;
  135.   if(key == 27) {
  136.     getch();  /* aa nothing */
  137.     if((s=strchr(k1, getch())) != NULL && (key = k2[s-k1]) > 'a')
  138.       flag[ALT]++;
  139.     return key&0x1F;
  140.   }
  141.   return key;
  142. }
  143.